package com.yycx.module.bus.provider.handler.process.listener;

import com.yycx.module.bus.client.entity.BusDrugsPlan;
import com.yycx.module.bus.provider.service.BusDrugsPlanService;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 药品采购审核结束监听器
 *
 * @author zyf
 */
@Component
public class DrugsPlanProcessEndListener implements TaskListener {
    @Autowired
    private BusDrugsPlanService busDrugsPlanService;

    @Override
    public void notify(DelegateTask delegateTask) {
        Thread thread = Thread.currentThread();
        System.out.println("Thread name: " + thread.getName());
        String businessKey = delegateTask.getVariable("businessKey", String.class);
        System.out.println("businessKey:" + businessKey);
        BusDrugsPlan busDrugsPlan = busDrugsPlanService.getById(businessKey);
        //采购审批结束
        busDrugsPlan.setCheckState(2);
        busDrugsPlanService.updateById(busDrugsPlan);

    }
}
